package com.gywj.race.controller.api;

import com.gywj.race.config.result.AjaxResultHandler;
import com.gywj.race.dto.SendSmsDto;
import com.gywj.race.service.SendSmsService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
public class SendSmsController {
    @Resource
    private SendSmsService sendSmsService;

    @PostMapping("/send/sms")
    public Map<String, Object> sendSms(@RequestBody SendSmsDto sendSmsDto) {
        try {
            String mobile = sendSmsDto.getMobile();
            Map paramJsonString = sendSmsDto.getParamJsonString();
            sendSmsService.sendSms(mobile,paramJsonString);
            return AjaxResultHandler.Success("发送短信成功");
        } catch (Exception e) {
            return AjaxResultHandler.Failed(e.getMessage());
        }
    }

}
